/*
 * Decompiled with CFR 0.150.
 * 
 * Could not load the following classes:
 *  cn.hutool.core.util.ObjectUtil
 *  cn.hutool.core.util.StrUtil
 *  com.alibaba.fastjson.JSON
 *  de.felixroske.jfxsupport.FXMLController
 *  javafx.fxml.FXML
 *  javafx.fxml.Initializable
 *  javafx.scene.control.Alert
 *  javafx.scene.control.Alert$AlertType
 *  javafx.scene.control.TextField
 *  javafx.scene.layout.AnchorPane
 *  javafx.stage.Modality
 *  org.springframework.beans.factory.annotation.Autowired
 */
package com.gys.controller.salesReceipts;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.gys.common.business.SalesReceiptsUtil;
import com.gys.common.data.HttpJson;
import com.gys.common.util.CacheUtil;
import com.gys.common.util.CommonUtil;
import com.gys.common.util.ConstUtil;
import com.gys.common.util.ValidationUtil;
import com.gys.controller.BaseController;
import com.gys.controller.index.IndexController;
import com.gys.controller.replenish.AddReplenishController;
import com.gys.controller.replenish.ReplenishController;
import com.gys.controller.salesReceipts.ApproveChangePriceController;
import com.gys.controller.salesReceipts.SalesReceiptsMainController;
import com.gys.data.example.GetLoginStoreOutData;
import com.gys.view.salesReceipts.ApproveChangePriceView;
import de.felixroske.jfxsupport.FXMLController;
import java.math.BigDecimal;
import java.net.URL;
import java.util.HashMap;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Modality;
import org.springframework.beans.factory.annotation.Autowired;

@FXMLController
public class SingleChangePriceController
extends BaseController
implements Initializable {
    private final int pageSize = ConstUtil.DEFAULT_PAGESIZE;
    private final int defaultPageCount = ConstUtil.DEFAULT_PAGECOUNT;
    @FXML
    private AnchorPane pane;
    @FXML
    private TextField price;
    @Autowired
    private ReplenishController acceptController;
    @Autowired
    private IndexController indexController;
    @Autowired
    private AddReplenishController addReplenishController;
    @Autowired
    private SalesReceiptsMainController salesReceiptsMainController;
    @Autowired
    private ApproveChangePriceController approveChangePriceController;
    private String changePrice;

    public void initialize(URL location, ResourceBundle resources) {
        this.init();
    }

    @Override
    public void init() {
        if (ObjectUtil.isEmpty(this.pane)) {
            return;
        }
        this.price.setText("");
    }

    @FXML
    private void changePrice() {
        this.changePrice = this.price.getText();
        if (StrUtil.isBlank((CharSequence)this.changePrice) || !ValidationUtil.checkPositiveNumberGtZero2F(this.changePrice)) {
            Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", "\u4ef7\u683c\u5fc5\u987b\u5927\u4e8e0\uff0c\u4e14\u6700\u591a2\u4f4d\u5c0f\u6570\uff01");
            alert.showAndWait();
            return;
        }
        this.changePrice = CommonUtil.format2(Float.valueOf(this.changePrice).floatValue());
        HashMap<String, Object> param = new HashMap<String, Object>();
        param.put("prcStore", ((GetLoginStoreOutData)CacheUtil.get("store")).getStoCode());
        HttpJson rsp = SalesReceiptsUtil.getStoreDiscount(param);
        if (rsp.isSuccess()) {
            String discount = (String)JSON.parseObject((String)rsp.getMsg(), String.class);
            BigDecimal rate = new BigDecimal(this.changePrice).divide(new BigDecimal(this.salesReceiptsMainController.getLsPriceString()), 2, 4).multiply(new BigDecimal(100));
            if (rate.compareTo(new BigDecimal(discount)) < 0) {
                this.approveChangePriceController.init();
                CommonUtil.showView(ApproveChangePriceView.class, Modality.APPLICATION_MODAL);
            } else {
                this.salesReceiptsMainController.singleChangePriceDo(this.changePrice);
                this.pane.getScene().getWindow().hide();
            }
        } else {
            Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", rsp.getMsg());
            alert.showAndWait();
            return;
        }
    }

    @FXML
    public void closeWindows() {
        this.pane.getScene().getWindow().hide();
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public int getDefaultPageCount() {
        return this.defaultPageCount;
    }

    public AnchorPane getPane() {
        return this.pane;
    }

    public TextField getPrice() {
        return this.price;
    }

    public ReplenishController getAcceptController() {
        return this.acceptController;
    }

    public IndexController getIndexController() {
        return this.indexController;
    }

    public AddReplenishController getAddReplenishController() {
        return this.addReplenishController;
    }

    public SalesReceiptsMainController getSalesReceiptsMainController() {
        return this.salesReceiptsMainController;
    }

    public ApproveChangePriceController getApproveChangePriceController() {
        return this.approveChangePriceController;
    }

    public String getChangePrice() {
        return this.changePrice;
    }

    public void setPane(AnchorPane pane) {
        this.pane = pane;
    }

    public void setPrice(TextField price) {
        this.price = price;
    }

    public void setAcceptController(ReplenishController acceptController) {
        this.acceptController = acceptController;
    }

    public void setIndexController(IndexController indexController) {
        this.indexController = indexController;
    }

    public void setAddReplenishController(AddReplenishController addReplenishController) {
        this.addReplenishController = addReplenishController;
    }

    public void setSalesReceiptsMainController(SalesReceiptsMainController salesReceiptsMainController) {
        this.salesReceiptsMainController = salesReceiptsMainController;
    }

    public void setApproveChangePriceController(ApproveChangePriceController approveChangePriceController) {
        this.approveChangePriceController = approveChangePriceController;
    }

    public void setChangePrice(String changePrice) {
        this.changePrice = changePrice;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof SingleChangePriceController)) {
            return false;
        }
        SingleChangePriceController other = (SingleChangePriceController)o;
        if (!other.canEqual(this)) {
            return false;
        }
        if (this.getPageSize() != other.getPageSize()) {
            return false;
        }
        if (this.getDefaultPageCount() != other.getDefaultPageCount()) {
            return false;
        }
        AnchorPane this$pane = this.getPane();
        AnchorPane other$pane = other.getPane();
        if (this$pane == null ? other$pane != null : !this$pane.equals(other$pane)) {
            return false;
        }
        TextField this$price = this.getPrice();
        TextField other$price = other.getPrice();
        if (this$price == null ? other$price != null : !this$price.equals(other$price)) {
            return false;
        }
        ReplenishController this$acceptController = this.getAcceptController();
        ReplenishController other$acceptController = other.getAcceptController();
        if (this$acceptController == null ? other$acceptController != null : !(this$acceptController).equals(other$acceptController)) {
            return false;
        }
        IndexController this$indexController = this.getIndexController();
        IndexController other$indexController = other.getIndexController();
        if (this$indexController == null ? other$indexController != null : !(this$indexController).equals(other$indexController)) {
            return false;
        }
        AddReplenishController this$addReplenishController = this.getAddReplenishController();
        AddReplenishController other$addReplenishController = other.getAddReplenishController();
        if (this$addReplenishController == null ? other$addReplenishController != null : !(this$addReplenishController).equals(other$addReplenishController)) {
            return false;
        }
        SalesReceiptsMainController this$salesReceiptsMainController = this.getSalesReceiptsMainController();
        SalesReceiptsMainController other$salesReceiptsMainController = other.getSalesReceiptsMainController();
        if (this$salesReceiptsMainController == null ? other$salesReceiptsMainController != null : !(this$salesReceiptsMainController).equals(other$salesReceiptsMainController)) {
            return false;
        }
        ApproveChangePriceController this$approveChangePriceController = this.getApproveChangePriceController();
        ApproveChangePriceController other$approveChangePriceController = other.getApproveChangePriceController();
        if (this$approveChangePriceController == null ? other$approveChangePriceController != null : !(this$approveChangePriceController).equals(other$approveChangePriceController)) {
            return false;
        }
        String this$changePrice = this.getChangePrice();
        String other$changePrice = other.getChangePrice();
        return !(this$changePrice == null ? other$changePrice != null : !this$changePrice.equals(other$changePrice));
    }

    protected boolean canEqual(Object other) {
        return other instanceof SingleChangePriceController;
    }

    public int hashCode() {
        int PRIME = 59;
        int result = 1;
        result = result * 59 + this.getPageSize();
        result = result * 59 + this.getDefaultPageCount();
        AnchorPane $pane = this.getPane();
        result = result * 59 + ($pane == null ? 43 : $pane.hashCode());
        TextField $price = this.getPrice();
        result = result * 59 + ($price == null ? 43 : $price.hashCode());
        ReplenishController $acceptController = this.getAcceptController();
        result = result * 59 + ($acceptController == null ? 43 : ($acceptController).hashCode());
        IndexController $indexController = this.getIndexController();
        result = result * 59 + ($indexController == null ? 43 : ($indexController).hashCode());
        AddReplenishController $addReplenishController = this.getAddReplenishController();
        result = result * 59 + ($addReplenishController == null ? 43 : ($addReplenishController).hashCode());
        SalesReceiptsMainController $salesReceiptsMainController = this.getSalesReceiptsMainController();
        result = result * 59 + ($salesReceiptsMainController == null ? 43 : ($salesReceiptsMainController).hashCode());
        ApproveChangePriceController $approveChangePriceController = this.getApproveChangePriceController();
        result = result * 59 + ($approveChangePriceController == null ? 43 : ($approveChangePriceController).hashCode());
        String $changePrice = this.getChangePrice();
        result = result * 59 + ($changePrice == null ? 43 : $changePrice.hashCode());
        return result;
    }

    public String toString() {
        return "SingleChangePriceController(pageSize=" + this.getPageSize() + ", defaultPageCount=" + this.getDefaultPageCount() + ", pane=" + this.getPane() + ", price=" + this.getPrice() + ", acceptController=" + this.getAcceptController() + ", indexController=" + this.getIndexController() + ", addReplenishController=" + this.getAddReplenishController() + ", salesReceiptsMainController=" + this.getSalesReceiptsMainController() + ", approveChangePriceController=" + this.getApproveChangePriceController() + ", changePrice=" + this.getChangePrice() + ")";
    }
}

